package com.eqdd.yiqidian.ui.mine.pizhun;

import android.os.Bundle;
import android.util.SparseArray;
import android.view.View;

import com.eqdd.yiqidian.base.AppConstent;
import com.eqdd.yiqidian.base.BaseInfoActivity;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.rebuild.CarPaperInfoBean;
import com.eqdd.yiqidian.bean.rebuild.RenliInfoBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditEnterBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditHintBean;
import com.eqdd.yiqidian.http.DialogCallBack;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.http.HttpResult;
import com.eqdd.yiqidian.ui.gongneng.car.CarInfoActivity;
import com.eqdd.yiqidian.ui.gongneng.renshi.zuzhiguanli.CareerDescActivity;
import com.eqdd.yiqidian.ui.mine.UserCardActivity;
import com.eqdd.yiqidian.ui.mine.renwu.TextActivity;
import com.eqdd.yiqidian.utils.DateUtil;
import com.eqdd.yiqidian.utils.ToastUtil;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

import java.util.HashMap;
import java.util.List;

public class RenliInfoActivity extends BaseInfoActivity {
    private Bundle bundle;
    private RenliInfoBean.MpnInfoBean mpnInfo;


    @Override
    public void initTitle() {
        initTopTitleBar(View.VISIBLE, "详情");


    }

    @Override
    protected void checkPost() {
        OkGo.<HttpResult>post(HttpConfig.BASE_URL + HttpConfig.RENLI_CHECK)
                .params("userGuid", AppConstent.user.getGuid())
                .params("mpnId", mpnInfo.getId())
                .params("remark", dealText(dataBinding.etRemark.getText().toString()))
                .params("isapproved", dataBinding.rbAgree.isChecked() ? 1 : -1)
                .execute(new DialogCallBack<HttpResult>(this) {
                    @Override
                    public void onSuccess(Response<HttpResult> response) {
                        HttpResult httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            setResult(Config.DELETE);
                            finish();
                        }
                    }
                });
    }

    @Override
    protected void itemClick(int position) {
        switch (slimAdapterEx.getDataItem(position).getPosition()) {
            case 0:
                bundle = new Bundle();
                bundle.putString(Config.GUID, mpnInfo.getCreater());
                startActivity(UserCardActivity.class, bundle);
                break;
            case 8:
                bundle = new Bundle();
                bundle.putString(Config.TITLE, "招聘原因");
                bundle.putString(Config.CONTENT, mpnInfo.getRecruitReason());
                startActivity(TextActivity.class, bundle);
                break;
            case 9:
                Bundle bundle = new Bundle();
                bundle.putBoolean(Config.IS_UPDATE, false);
                bundle.putInt(Config.ID, mpnInfo.getPostid());
                bundle.putString("postName", mpnInfo.getPostName());
                bundle.putString("depName", mpnInfo.getDepName());
                startActivity(CareerDescActivity.class, bundle);
                break;
            case 11:
                bundle = new Bundle();
                bundle.putString(Config.TITLE, "备注");
                bundle.putString(Config.CONTENT, mpnInfo.getRemark());
                startActivity(TextActivity.class, bundle);
                break;
        }
    }


    @Override
    public void setView() {
        OkGo.<RenliInfoBean>post(HttpConfig.BASE_URL + HttpConfig.RENLI_INFO)
                .params("mpnId", id)
                .params("userGuid", AppConstent.user.getGuid())
                .execute(new DialogCallBack<RenliInfoBean>(this) {
                    @Override
                    public void onSuccess(Response<RenliInfoBean> response) {
                        RenliInfoBean httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            mpnInfo = httpResult.getMpnInfo();
                            List<RenliInfoBean.CheckInfoBean> checkInfos = httpResult.getCheckInfo();
                            if (who != 0) {
                                data.add(new SlimEditEnterBean("申请人", "", 0, ""));
                            }
                            data.add(new SlimEditHintBean("需求编码", mpnInfo.getCode(), 1));
                            data.add(new SlimEditHintBean("申请职位", mpnInfo.getPostName(), 2));
                            data.add(new SlimEditHintBean("所属部门", mpnInfo.getDepName(), 3));
                            data.add(new SlimEditHintBean("职位编制人数", mpnInfo.getBZrenshu() + "人", 4));
                            data.add(new SlimEditHintBean("职位现有人数", mpnInfo.getXYrenshu() + "人", 5));
                            data.add(new SlimEditHintBean("待离职人数", mpnInfo.getDLZrenshu() + "人", 6));
                            data.add(new SlimEditHintBean("申请人数", mpnInfo.getRecruitRenShu() + "人", 7));
                            data.add(new SlimEditHintBean("招聘原因", mpnInfo.getRecruitReason(), 8).setDeal(true));
                            data.add(new SlimEditHintBean("工作职责", "查看", 9).setDeal(true));
                            data.add(new SlimEditHintBean("要求到岗时间", mpnInfo.getDemandAtWorkTime(), 10));
                            data.add(new SlimEditHintBean("备注", mpnInfo.getRemark(), 11));
                            data.add(new SlimEditHintBean("招聘渠道", mpnInfo.getRecruitType(), 12));
                            slimAdapterEx.updateData(data);
                            if (who >= 1 && status == 0) {
                                dataBinding.llDownRoot.setVisibility(View.VISIBLE);
                            }
                        }
                    }
                });
    }


}
